package org.meluk.billboard.jpa.seabattle;

import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import org.meluk.billboard.jpa.BasePoint;

@Entity
@Table(name = "SBPoint", uniqueConstraints = {
    @UniqueConstraint(columnNames = {"board_id", "x", "y"})})
public class SBPoint extends BasePoint {

    private Boolean isAlive;
    private Boolean isWithShip;

    public SBPoint() {
    }

    public SBPoint(Boolean isAlive, Boolean isWithShip, Integer x, Integer y) {
        super(x, y);
        this.isAlive = isAlive;
        this.isWithShip = isWithShip;
    }
    @ManyToOne
    @JoinColumn(name = "ship_id")
    private Ship ship;
    @ManyToOne
    @JoinColumn(name = "board_id")
    private SBBoard board;

    public Boolean getIsAlive() {
        return isAlive;
    }

    public void setIsAlive(Boolean isAlive) {
        this.isAlive = isAlive;
    }

    public Boolean getIsWithShip() {
        return isWithShip;
    }

    public void setIsWithShip(Boolean isWithShip) {
        this.isWithShip = isWithShip;
    }

    public Ship getShip() {
        return ship;
    }

    public void setShip(Ship ship) {
        this.ship = ship;
    }

    public SBBoard getBoard() {
        return board;
    }

    public void setBoard(SBBoard board) {
        this.board = board;
    }

    @Override
    public String toString() {
        return "SBPoint{" + "x =" + getX() + "y=" + getY() + "isAlive=" + isAlive + ", isWithShip=" + isWithShip + ", ship is null=" + (ship==null) + ", board=" + board + '}';
    }
}
